from rest_framework.permissions import BasePermission

SAFE_METHODS = ('GET', 'HEAD', 'OPTIONS')


class CustomPermission(BasePermission):

    def has_permission(self, request, view):
        user = request.user
        if user.is_superuser:
            return True
        code = f'{view.basename}:{view.action}'
        return user.has_permission_code(code)

    def has_object_permission(self, request, view, obj):
        return True
